<template>
  <view class="cu-card case no-card">
    <view
      @click="toProject(item.id)"
      class="cu-item shadow"
      v-for="(item, index) in projects"
      :key="index">
      <view class="image">
        <image :src="item.cover" mode="widthFix"></image>
        <view class="cu-tag bg-gradual-orange">{{ item.category }}</view>
        <view class="cu-bar bg-shadeBottom">
          <text class="text-cut">{{ item.summary }}</text>
        </view>
      </view>
      <view class="cu-list menu-avatar">
        <view class="cu-item">
          <view class="margin-lr flex-sub">
            <view class="item-name text-bold text-grey text-lg">
              {{ item.title }}
            </view>
            <view class="text-gray text-df flex justify-between">
              {{ item.createdTime }}
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import {ref} from 'vue';
import request from "@/lib/request.js";
import useApp from "@/hooks";
const { $ } = useApp();
const projects = ref([]);
/**
 * 查看详情
 */
function toProject(pid){
	uni.navigateTo({
		url:'project?id=' + pid
	})
}
/**
 * 查询首页推荐项目
 */
function queryIndexRec() {
  $.get($.api + "/pms/articles", { pageSize: 5, pageNum: 1 }).then((res) => {
    //console.log(res);
	let arr = res.data.data.content;
	arr = $.buildArrayEleReplace(arr,'cover','/dev-api', $.api)
	console.log(arr)
	projects.value = arr;
  });
}
queryIndexRec();
</script>

<style></style>
